package com.pet.system.service.impl;

import com.pet.common.utils.DateUtils;
import com.pet.system.domain.PetCustomerUser;
import com.pet.system.mapper.PetCustomerUserMapper;
import com.pet.system.service.IPetCustomerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 客户商家关联Service业务层处理
 *
 * @author pet
 * @date 2022-10-15
 */
@Service
public class PetCustomerUserServiceImpl implements IPetCustomerUserService {
    @Autowired
    private PetCustomerUserMapper petCustomerUserMapper;

    /**
     * 查询客户商家关联列表
     *
     * @param userId 客户商家关联
     * @return 客户商家关联
     */
    @Override
    public List<Map<String, Object>> selectPetCustomerCustomerListByUserId(Long userId) {
        List<Map<String, Object>> maps = petCustomerUserMapper.selectPetCustomerCustomerListByUserId(userId);

        return maps;
    }

    /**
     * 新增客户商家关联
     *
     * @param petCustomerUser 客户商家关联
     * @return 结果
     */
    @Override
    public int insertPetCustomerUser(PetCustomerUser petCustomerUser) {
        petCustomerUser.setCreateTime(DateUtils.getNowDate());
        return petCustomerUserMapper.insertPetCustomerUser(petCustomerUser);
    }

    /**
     * 修改客户商家关联
     *
     * @param petCustomerUser 客户商家关联
     * @return 结果
     */
    @Override
    public int updatePetCustomerUser(PetCustomerUser petCustomerUser) {
        petCustomerUser.setUpdateTime(DateUtils.getNowDate());
        return petCustomerUserMapper.updatePetCustomerUser(petCustomerUser);
    }

    /**
     * 批量删除客户商家关联
     *
     * @param ids 需要删除的客户商家关联主键
     * @return 结果
     */
    @Override
    public int deletePetCustomerUserByIds(Long[] ids) {
        return petCustomerUserMapper.deletePetCustomerUserByIds(ids);
    }

    /**
     * 删除客户商家关联信息
     *
     * @param id 客户商家关联主键
     * @return 结果
     */
    @Override
    public int deletePetCustomerUserById(Long id) {
        return petCustomerUserMapper.deletePetCustomerUserById(id);
    }
}
